﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class App_Form_DaoTao_ds_sv_hocbong : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            namhoc.DataSource = c_ht.Fdt_NAM_HOC();
            namhoc.DataBind();

            System.Data.DataTable b_dt = new System.Data.DataTable();
            LIB.Core.LibTable.AddNewCol(ref b_dt, new string[] { "id", "ten" });
            LIB.Core.LibTable.AddNewRow(ref b_dt, new string[] { "HKI", "Học kỳ 1" });
            LIB.Core.LibTable.AddNewRow(ref b_dt, new string[] { "HKII", "Học kỳ 2" });

            LIB.Core.LibUntil.P_DROP_BANG(hocky, b_dt);

            System.Data.DataTable b_dt_lop = new System.Data.DataTable();
            b_dt_lop = LIB.Data.SqlData.GetData("", "PLOP_LKE_DROP");
            LIB.Core.LibUntil.P_DROP_BANG(lop, b_dt_lop);
            lop.Items.Insert(0, new ListItem("Chọn tất", ""));
            string qr = Request.QueryString["loai"];
            loai.Value = qr;
            if (qr == "1")
            {
                d.Style.Add("display", "none");
                ma_sv.Style.Add("display", "block");
            }
            else
            {
                d.Style.Add("display", "block");
                ma_sv.Style.Add("display", "none");
            }
        }
    }
    protected void namhoc_SelectedIndexChanged(object sender, EventArgs e)
    {
        string nam = this.namhoc.SelectedValue;

        System.Data.DataTable b_dt_lop = new System.Data.DataTable();
        b_dt_lop = LIB.Data.SqlData.GetData(nam, "PLOP_LKE_DROP");
        LIB.Core.LibUntil.P_DROP_BANG(lop, b_dt_lop);
        lop.Items.Insert(0, new ListItem("Chọn tất", ""));
    }
    protected void In_Click(object sender, EventArgs e)
    {
        try
        {

            System.Data.DataSet b_ds=new System.Data.DataSet();
            if(loai.Value=="2")
              b_ds = c_nhapdiem.Fs_DANH_SACH_HBONG(namhoc.SelectedValue, lop.SelectedValue, lop.Items[lop.SelectedIndex].Text, hocky.SelectedValue);
            else if(loai.Value=="1")
               b_ds = c_nhapdiem.Fds_BANG_DIEM_CT(namhoc.SelectedValue, ma_sv.Text, hocky.SelectedValue, hocky.Items[hocky.SelectedIndex].Text);

            string str = "~/App_Form/bc/xembc.aspx?kieu_in=I";
            ht_bc.P_MO(this, str, "", 0x4b0, 700, b_ds);
        }
        catch (Exception ex)
        {
            LIB.Core.LibUntil.P_LOI(this, ex.Message);
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            System.Data.DataSet b_ds = new System.Data.DataSet();
            if (loai.Value == "2")
                b_ds = c_nhapdiem.Fs_DANH_SACH_HBONG(namhoc.SelectedValue, lop.SelectedValue, lop.Items[lop.SelectedIndex].Text, hocky.SelectedValue);
            else if (loai.Value == "1")
                b_ds = c_nhapdiem.Fds_BANG_DIEM_CT(namhoc.SelectedValue, ma_sv.Text, hocky.SelectedValue, hocky.Items[hocky.SelectedIndex].Text);

            string str = "~/App_Form/bc/xembc.aspx?kieu_in=E";
            ht_bc.P_MO(this, str, "", 0x4b0, 700, b_ds);
        }
        catch (Exception ex)
        {
            LIB.Core.LibUntil.P_LOI(this, ex.Message);
        }
    }
}